 #define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    int digitSum(int n)
    {
        int sum = 0;
        while (n)
        {
            int t = n % 10;
            sum += t * t;
            n /= 10;
        }
        return sum;
    }

    bool isHappy(int n) {
        int slow = n, fast = digitSum(n);
        while (slow != fast)
        {
            slow = digitSum(slow);
            fast = digitSum(digitSum(fast));
        }
        return slow == 1 ? true : false;
    }
};

class Solution {
public:
    int maxArea(vector<int>& height) {
        int left = 0, right = height.size() - 1, ret = 0;

        while (left < right)
        {
            int v = min(height[left], height[right]) * (right - left);
            ret = max(ret, v);

            if (height[left] < height[right]) left++;
            else right--;
        }

        return ret;
    }
};